<?php

class VanillaMediaImage extends BaseVanillaMediaImage
{
    public function delete(PropelPDO $con = null)
	{
        $c = new Criteria();
        $c->add(VanillaMediaImagePeer::ID, $this->getId());

        $imagei18 = VanillaMediaImageI18nPeer::doSelect($c);

        foreach($imagei18 as $image) {
            $image->delete();
        }

        parent::delete();

        unlink(sfConfig::get('sf_upload_dir').'/media/'.$this->getImg());
        unlink(sfConfig::get('sf_upload_dir').'/media/thumb/'.$this->getImg());
    }
}
